<?php
if(!class_exists('MAIN_Controller_Action')) Zend_Loader :: loadClass('MAIN_Controller_Action');
class Front_IndexController extends MAIN_Controller_Action {
	public function indexAction() {
		$view = $this->_getView();
		$generic = $this->getGeneric();
		$logonDetail = $generic->getLoginDetail();
		$view->assign("logonDetail",$logonDetail[0]);
		$view->output('index.tpl');
    }
    public function contactAction() {
    	$params   = $this->getParams();
    	//_print($params['contact_cmd']);
    	if($params['contact_cmd']	==	"add"){
    		$strTo	=	"PPO@hbc.co.th";
    		$strSubject	=	"Contrack From E-Link".$params['txt_con_name'];
    		$strHeader	=	"Content-type: text/html; charset=UTF-8\n";
    		$strHeader	.=	"From: ".$params['txt_con_name'];
    		$staMessage	=	"<table width='700' border='0' align='center'>
    											<tr>
    												<td colspan='4' align='left'>เรียน ทีม PPO</td>
    											</tr>
												 <tr>
													 <td width='20%' align='right'>&nbsp;</td>
													 <td align='left' colspan='3'>มีข้อความจาก คุณ&nbsp;".$params['txt_con_name']."&nbsp;(".$params['txt_con_mail'].")&nbsp;ส่งผ่านโดยระบบ E-link มีข้อความดังนี้ :</td>
												 </tr>
												 <tr>
													 <td colspan='4' align='left' valign='top'>".$params['ta_detail']."</td>	
												 </tr>
												</table>";
    		//$strMessage	=	$params['ta_detail'];
    		$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader);
    		if($flgSend){
    			$answer	=	"ส่งข้อความเรียบร้อย";
    		} else {
    			$answer	=	"ไม่สามารถส่งข้อความได้";
    		}
    		echo '<script>alert("'.$answer.'");</script>';
    	}
    	//_print($answer);    	
    	$view = $this->_getView();
    	$view->output('contact/contact.tpl');
    }
    
    
    public function aboutAction() {
    	$view = $this->_getView();
    	$view->output('index.tpl');
    }
	public function logoutAction(){
		header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
		header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
		header("Cache-Control: post-check=0, pre-check=0", false);
		header("Pragma: no-cache");
		
		if(!class_exists('Zend_Auth'))Zend_loader :: loadClass('Zend_Auth');
		$auth = Zend_Auth :: getInstance();
		$identity = $auth->getIdentity();
		
		
		if($identity) {
	        $auth->clearIdentity();
        }
        unset($_SESSION);
		session_unset();
		session_destroy();
		setcookie('username_log', null, time() - 3600);
		setcookie('password_log', null, time() - 3600);
		$this->_redirect($logoutUrl);
    }
}
?>